<!DOCTYPE html>
<html>
<head>
<include file="Public:meta"/>
</head>
<body>

<div class="easyui-panel" title="修改登录密码">
	<form id="edit-form" method="post">
	<table class="form-table" style="margin-top:30px;">
    	<tr>
        	<td style="width: 30%; border-color: #ccc; background:#dcdcdc; border-width: 1px 0 1px 0;" align="right">旧密码</td>
            <td style="width: 70%; border-color: #ccc; border-width: 1px 0 1px 0;">
           <input class="easyui-textbox" type="password" name="oldpwd" id="oldpwd" required style="width: 60%;">
            </td>
        </tr>
    	<tr>
        	<td style="width: 30%; border-color: #ccc; background:#dcdcdc;" align="right">新密码</td>
            <td style="width: 70%; border-color: #ccc;">
            <input class="easyui-textbox" type="password" name="newpwd" id="newpwd" required style="width: 60%;">
            </td>
        </tr>
        <tr>
        	<td style="width: 30%; border-color: #ccc; background:#dcdcdc;" align="right">再次输入新密码</td>
            <td style="width: 70%; border-color: #ccc;">
            <input type="password" class="easyui-textbox " name="cfnewpwd" id="cfnewpwd" required validType="equals['#newpwd']"style="width:60%;">
            </td>
        </tr>
        <tr>
        	<td style="width: 30%; border-color: #ccc;" align="right"></td>
            <td style="width: 70%; border-color: #ccc;">
            <a href="javascript:void(0);" onClick="$('#edit-form').submit();" class="easyui-linkbutton" iconCls="icon-save"> 保 存 </a>
            </td>
        </tr>
    </table>
	</form>
</div>
    
<script type="text/javascript">

	$.extend($.fn.validatebox.defaults.rules, {
		equals: {
			validator: function(value,param){
				return value == $(param[0]).val();
			},
			message: '两次输入密码不一致！'
		}
	});
		
	$(function(){
		
		var saveUrl = "{:U('System/changePassword')}?act=save";
		$('#edit-form').form({
			url:saveUrl,
			onSubmit: function(){
				//进行表单验证
				//如果返回false阻止提交
				return $(this).form('validate');
			},
			success:function(data){
				if(data == 1){
					$.messager.alert('操作提示','登录密码已修改，请牢记！','info',function(){
						$('#pwd-win').dialog('close');
					});
				}else{
					var msg = data == 2 ? '旧密码错误，修改操作失败！' : '修改密码操作失败!';
					$.messager.alert('操作提示',msg,'error');
				}
			}
		});

		$(".form-table td").hover(function(){
			$(this).css("borderColor","#f60");
			var index = $(this).index();
			if(index % 2 == 0){
				$(this).next().css("borderColor","#f60");
			}else{
				$(this).prev().css("borderColor","#f60");
			}
		},function(){
			$(this).css("borderColor","#ccc");
			var index = $(this).index();
			if(index % 2 == 0){
				$(this).next().css("borderColor","#ccc");
			}else{
				$(this).prev().css("borderColor","#ccc");
			}
		});

	});
</script>


</body>
</html>